<?php
namespace App\Logic\ZiNiao\Api;

use App\Libs\ZiNiao\RequireAppToken;
use App\Libs\ZiNiao\RequireOpenClient;
use App\Libs\ZiNiao\RPARequest\PlansDriversOnRequest;
use Exception;
class PlansDriversOn
{
    /**
     * 启用计划
     * @param array $bizContent ['planIds' => "1271,1655272611,1655272942"]
     * @return mixed
     */
    public function exe($bizContent = [])
    {
        $openClient = RequireOpenClient::getInstance();
        $requireAppToken = new RequireAppToken();
        $appAuthToken = $requireAppToken->getAppToken($openClient);
        $request = new PlansDriversOnRequest();
        $request->setBizContent(json_encode($bizContent));
        $result = $openClient->executeAppToken($request,$appAuthToken);// 发送请求
        $result_decode = json_decode($result);
        if (($result_decode->code === 0 or $result_decode->code === '0') and !isset($result_decode->sub_code)) {
            return $result_decode->data;
        }else {
            report(new Exception('PlansDriversOn失败:' . $result,223));
            die(0);
        }
    }
}
